import store from 'store'
/**
 * 本地存储工具
 */
export default {
  saveT: (key, source) => {
    store.set(key, source)
  },
  getT: (key) => {
    return store.get(key)
  },
  /**
   * 判断是null还是一个空对象
   * @param {*} key
   */
  isEmpty: (key) => {
    if (!store.get(key)) {
      return true
    } else if (
      typeof store.get(key) === 'object' &&
      Object.keys(store.get(key)).length === 0
    ) {
      //是个空对象{}
      return true
    } else if (store.get(key) === '') {
      return true
    } else {
      return false
    }
  },
  removeT: (key) => {
    return store.remove(key)
  },
  clear: () => {
    return store.clearAll()
  },
}
